mui.init();

mui.plusReady(function(){
	
	if(plus.navigator.getCookie("loginname")!=null){
			$("#loginname").val(plus.navigator.getCookie("loginname"));
	}else{
			$("#loginname").val("");
			$("#password").val("");
	}
			
	})           
           
function severCheck() {
	
		
			
        var loginname = $("#loginname").val();
		var password = $("#password").val();
		if(loginname==""||password==""){
					$("#doc-vld-msg").submit();
					return false;
		 }	
		var id = "body-loading";
  		$(window).loading({action:"open",id:id,font:40}); 
		var code = "qqbigbug"+loginname+",zx,"+password;
		mui.getJSON ("json/locat.json", function (data) {
			var  locat=data["url"];
			var factoryid=data["factoryid"];
	        mui.ajax(locat+"/clientUser/login", {
	            type: "POST",
	            data: {
	                KEYDATA: code,
	                factoryid: factoryid
	            },
	            success: function(data, status, xhr) {
	            		var time = setTimeout(function(){
			   				//关闭
			   				$(window).loading({action:"close",id:id});
			   			},100);
			   			plus.navigator.setCookie("sessionId",data.sessionId);
			   			plus.navigator.setCookie("factoryid",factoryid);
						if("success" == data.result){
							plus.navigator.setCookie('loginname',loginname, {
								expires : 7
								});	
							plus.navigator.setCookie('password', $("#password").val(), {
								expires : 7
								});
								//alert(plus.navigator.getCookie("loginname"));
								//alert(plus.navigator.getCookie("password"));
								window.location.href="user.html";
						}else if("usererror" == data.result){
								swal("用户名或密码错误");
								$("#loginname").focus();
						}else{	
								swal("缺少参数")
								$("#loginname").focus();
						}
	            },
	            error:function(data){
	            	plus.ui.toast("","服务异常","error");
	            }
	        });
    });  
}



 





